SRCDIR=../src/
OBJDIR=../obj/
OBJEXT=o

INCDIR1=../src/include
INCDIR2=../src/lib
INCDIR3=../src/CCore/inc
INCDIR4=../src/CCore/encode
INCDIR5=../src/CCore/version
INCDIR6=../src/CCore/parser
INCDIR7=../src/CCore/table
INCDIR8=../src/CCore/trace
INCDIR9=../src/CCore/trace/trace_ast
INCDIR10=../src/db/db_if
INCDIR11=../src/rule_if
INCDIR12=../src/rules
INC=-I$(INCDIR1) -I$(INCDIR2) -I$(INCDIR3) -I$(INCDIR4) -I$(INCDIR5) -I$(INCDIR6) -I$(INCDIR7) -I$(INCDIR8) -I$(INCDIR9) -I$(INCDIR10) -I$(INCDIR11) -I$(INCDIR12)

DEBUG=DEBUG
CMDRECORDER=RECORD_CMDLIST_LABEL
DEFINE=-D$(CMDRECORDER) -D$(DEBUG)

CC=gcc
CFLAG=-c -g -std=c99 -fPIC  $(INC) $(DEFINE)
CFLAG_E=-c -g -std=c99 $(INC) $(DEFINE)

LD=gcc
LFLAG=-lm -shared
LFLAG_E=-lm

MAIN_DIR=/root
LIB_DIR=$(MAIN_DIR)/bin
LIB_SQLITE3=$(LIB_DIR)/sqlite3.so
LIB_CCORE=$(LIB_DIR)/CCore.so
LIB_CRULE=$(LIB_DIR)/CRule.so

include CCore.mk
include core.mk
include CRule.mk
include rule.mk

all:CCore core CRule rule

SHARED_CCORE=$(LIB_DIR)/CCore.so
CCore: $(OBJ_CCORE)
	$(LD) $(LFLAG) -o$(SHARED_CCORE) $(OBJ_CCORE) $(LIB_SQLITE3)

EXEFILE_CORE=$(LIB_DIR)/core
core: $(OBJ_CORE) 
	$(LD) $(LFLAG_E) -o$(EXEFILE_CORE) $(OBJ_CORE) $(LIB_SQLITE3) $(LIB_CCORE)

SHARED_CRULE=$(LIB_DIR)/CRule.so
CRule: $(OBJ_CRULE)
	$(LD) $(LFLAG) -o$(SHARED_CRULE) $(OBJ_CRULE) $(LIB_CCORE)

EXEFILE_RULE=$(LIB_DIR)/rule
rule: $(OBJ_RULE)
	$(LD) $(LFLAG_E) -o$(EXEFILE_RULE) $(OBJ_RULE) $(LIB_SQLITE3) $(LIB_CCORE) $(LIB_CRULE) -lpthread